<template>
  <div class="con">
    <div class="contbox6_10">
      <p class="titlelist6_10">
        业务管理
        <span style="color: #999">&nbsp;&nbsp;/&nbsp;&nbsp;</span>业务订单
      </p>
      <div class="content">
        <div class="sousuojg6_10">
          <el-form ref="form" :model="form" label-width="100px">
            <el-form-item label="业务订单号">
              <el-input
                placeholder="请输入业务订单号"
                v-model="form.orderCode"
              ></el-input>
						</el-form-item>
						<el-form-item label="机构名称">
              <el-input
                placeholder="请输入机构名称"
                v-model="form.officeName"
              ></el-input>
						</el-form-item>
						<el-form-item label="机构ID">
              <el-input
                placeholder="请输入机构ID"
                v-model="form.officeUid"
              ></el-input>
						</el-form-item>
						 <el-form-item label="机构类型" style="float: left;">
              <el-select v-model="form.agtType" placeholder="请选择状态">
                <el-option label="全部" value></el-option>
                <el-option label="OEM" value="0" v-if="jurisdiction!=0"></el-option>
                <el-option label="普通代理" value="1"></el-option>
                <el-option label="渠道机构" value="3" v-if="jurisdiction!=0"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="订单状态" style="float: left;">
              <el-select
                v-model="form.orderStatus"
                clearable
                placeholder="请选择"
              >
                <el-option label="全部" value=""></el-option>
                <el-option label="已下单" value="0"></el-option>
                <el-option label="取消订单" value="1"></el-option>
              </el-select>
            </el-form-item>
						<el-form-item label="业务品牌">
              <el-input
                placeholder="请输入业务品牌"
                v-model="form.channelName"
              ></el-input>
						</el-form-item>
            <el-form-item label="申请时间">
              <el-date-picker
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="开始日期"
                v-model="form.startDate"
                style="width: 100%"
              ></el-date-picker>
              <div class="times">-</div>
              <el-date-picker
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="结束日期"
                v-model="form.endDate"
                style="width: 100%"
              ></el-date-picker>
            </el-form-item>
          </el-form>
        </div>
        <div class="buttons">
          <el-button
            v-if="isAuth('businessManageSearch')"
            type="primary"
            @click="handleSelectLists"
            >搜索</el-button
          >
          <el-button
            v-if="isAuth('businessManageReset')"
            @click="resetTheSearch"
            >重置</el-button
          >
          <el-button
            @click="exportFiles"
            class="butt"
            style="margin-left: 40px"
            type="primary"
            >批量导出</el-button
          >
        </div>
        <el-table
          :data="list"
          tooltip-effect="dark"
          :header-cell-style="{ background: '#F9FAFC', color: '#222' }"
          stripe
          border
          :row-style="{ height: '0px' }"
          :cell-style="{ padding: '0px' }"
          ref="multipleTable"
        >
					<el-table-column
            min-width="200"
            label="业务订单号"
            show-overflow-tooltip
            prop="orderCode"
          ></el-table-column>
					<el-table-column
            min-width="200"
            show-overflow-tooltip
            label="机构ID"
            prop="officeUid"
          ></el-table-column>
					<el-table-column
            min-width="200"
            label="机构名称"
            show-overflow-tooltip
            prop="officeName"
          ></el-table-column>
					<el-table-column
            min-width="200"
            label="机构类型"
            show-overflow-tooltip
            prop="agtType"
          ></el-table-column>
          <el-table-column
            min-width="200"
            label="业务品牌"
            prop="channelName"
            show-overflow-tooltip
          ></el-table-column>
           <el-table-column
            min-width="200"
            label="推广名称"
            prop="typeName"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            min-width="200"
            label="申请时间"
            prop="applyDate"
            show-overflow-tooltip
          ></el-table-column>
          <el-table-column
            min-width="120"
            label="我的成本(元)"
            show-overflow-tooltip
            prop="inFeeSum"
          ></el-table-column>
          <el-table-column
            min-width="100"
            label="已分润(元)"
            show-overflow-tooltip
            prop="outFeeSum"
          ></el-table-column>
          <el-table-column
            show-overflow-tooltip
            min-width="120px"
            label="订单状态"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.orderStat == 0 ? "下单" :scope.row.orderStat == 1 ?  "办卡已回结果":"" }}</span>
            </template>
          </el-table-column>
          <el-table-column show-overflow-tooltip min-width="100" label="操作">
            <template slot-scope="scope">
              <el-button type="text" @click="cat(scope.row)">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div style="font-size: 16px; margin-top: 30px">
          <el-pagination
            style="text-align: right"
            background
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page.sync="form.page"
            :page-sizes="[20, 50, 100]"
            :page-size="form.number"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
          ></el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import https from "../../plugins/https.js"
// 批量导出
import { exportFile } from "../../plugins/expord"
import { CompareDate } from "../../assets/js/commion";
export default {
  data() {
    return {
      total:"",
      form: {
        page:1,
        number:20,
        orderCode:"",
        officeName:"",
        agtType:"",
        channelName:"",
        startDate:"",
        endDate:"",
      },
      list: [],

    };
  },
  created(){
    this.jurisdiction = localStorage.getItem("jurisdiction")
    this.lists()
  },
	methods:{
    lists(){
      https.getBusOrderCreditList(this.form).then(res=>{
        if(res.data.code=="0000"){
          this.list=res.data.data
           for (var s = 0; s < this.list.length; s++) {
              this.list[s].agtType =
                this.list [s].agtType == 0 ? "OEM" : this.list [s].agtType == 1?"普通代理":"渠道机构";
            }
          this.total=res.data.total
        }
      })
    },
    //每页几条数据
    handleSizeChange(val) {
      this.form.number = val; //动态改变
      this.form.page = 1;
      this.lists();
    },
    //当前页
    handleCurrentChange(val) {
      this.form.page = val; //动态改变
      this.lists();
    },
    //搜索
    handleSelectLists(){
       this.form.page=1
        let bool = CompareDate(this.form.startDate, this.form.endDate);
      if (this.form.startDate != "" && this.form.endDate != "") {
        if (bool) this.lists();
        else this.warrys();
      } else {
        this.lists();
      }
    },
     // 校验时间的一个方法
    warrys() {
      layer.open({
        content: "结束时间不能早于开始时间",
        skin: "msg",
        time: 2 //1秒后自动关闭
      });
    },
    // 重置
    resetTheSearch(){
      this.form={
        page:1,
        number:20,
        orderCode:"",
        officeName:"",
        agtType:"",
        channelName:"",
        startDate:"",
        endDate:"",
      }
      this.lists()
    },
    //导出
    exportFiles(){
      exportFile("/api/business/busOrderCreditList/excel/export",this.form,"业务订单")
    },
    cat(val){
      this.$router.push({
        name:"bussinessOrderDetail",
        query:{
          id:val.id
        }
      })
    }
	}
};
</script>

<style scoped>
.con {
  position: relative;
}
/* 单独样式 */
.contbox6_10 {
  width: 100%;
  /* margin-left: 2%; */
  /*  height: 87.5vh; */
  overflow-x: auto;
  box-sizing: border-box;
  float: left;
}
.sousuojg6_10 {
  width: 100%;
}
.times {
  width: 20px;
  display: inline-block;
  text-align: center;
}
.buttons > .el-button {
  width: 100px;
  padding: 7px;
  height: 32px;
}
</style>
